<template>
	<view class="wrap">
		<view class="wrap__main" >
			<view class="main__code">
				<image :src="userInfo.code_path" mode="aspectFill" class="code__img"></image>
			</view>
			<view class="main__tips">我的邀請碼：{{userInfo.code}}</view>
			<view class="main__btn" @click="copyClick">複製粘貼</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return {
				userInfo:{}, //用户信息
			}
		},
		onLoad() {
			this.getUserQrCode()
		},
		methods:{
			// 获取用户二维码
			async getUserQrCode(){
				let res = await this.$api.getUserQrCode()
				if(res.code === 1 && res.data){
					this.userInfo = res.data
				}
			},
			// 复制点击
			copyClick(){
				let {code} = this.userInfo
				uni.setClipboardData({
					data: code,
					success: ()=> {
						uni.showToast({
							title:"复制成功",
							icon:"success"
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.wrap{
		height: 100vh;
		background: url('@/static/imgs/invite_bg.png') no-repeat center center;
		background-size:cover;
		@include flexCenter(column);
		padding-top: 350rpx;
		box-sizing: border-box;
		.wrap__main{
				@include flexCenter(column);
			.main__code{
				width: 320rpx;
				height: 320rpx;
				background: #1F72F4;
				border-radius: 20rpx;
				@include flexCenter(column);
				.code__img{
					width: 280rpx;
					height: 280rpx;
				}
			}
			.main__tips{
				font-size: 30rpx;
				font-weight: 800;
				color: #1F72F4;
				margin-top: 20rpx;
				text-align: center;
			}
			.main__btn{
				width: 402rpx;
				height: 96rpx;
				font-size: 36rpx;
				font-weight: 800;
				color: #FFFFFF;
				@include flexCenter();
				background: url('@/static/imgs/copy_btn.png') no-repeat center center;
				background-size: 100% 100%;
				margin-top: 36rpx;
			}
		}
	}
</style>